//
//  SINALocationSelectTableViewCell.m
//  sinashebao
//
//  Created by  androidlongs on 2018/4/8.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINALocationSelectTableViewCell.h"

@interface SINALocationSelectTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *locationName;

@property (weak, nonatomic) IBOutlet UILabel *locationDistance;


@property (weak, nonatomic) IBOutlet UIView *mainView;

@end

@implementation SINALocationSelectTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void)setModel:(SINALocationSelectModel *)model{
    
    
    
    _model = model;
    self.locationName.text = model.name;
    if ([model.distance integerValue]<1000) {
        self.locationDistance.text=[NSString stringWithFormat:@"%@m",model.distance];
    } else {
        self.locationDistance.text=[NSString stringWithFormat:@"%0.1fkm",[model.distance integerValue]*1.0f/1000];
    }
    

    if (model.isSelect) {
        self.mainView.backgroundColor=baseSelectColor;
        self.locationName.textColor=[UIColor whiteColor];
        self.locationDistance.textColor=[UIColor whiteColor];
    } else {
        self.locationName.textColor=[UIColor colorWithHexString:@"#212121"];
        self.mainView.backgroundColor=[UIColor colorWithHexString:@"#ffffff"];
         self.locationDistance.textColor=[UIColor colorWithHexString:@"#212121"];
    }

    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.mainView andWithBlick:^(UIView *view) {
        if (self.locationBlock) {
            self.locationBlock(model);
        }
    }];
    
}




@end
